package org.meiling.test;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

import org.meiling.util.Utils;

public class Rect {
	private int type;
	private int x;
	private int y;
	 int i;
	 int j;
	private Image show;
	public int iskong ;
	private boolean isClicked = false;
	public Rect(){}
	public Rect(int x,int y){
		this.x = x;
		this.y = y;
		this.type = Utils.rand.nextInt(5);
		setShow();
	}
	
	public Rect(int x,int y,int iskong,String ss){
		this.x = x;
		this.y = y;
		//空类型
		this.iskong=iskong;
	}
	
	public Rect(int x,int y,int type){
		this.x = x;
		this.y = y;
		this.type=type;
		setShow();
	}
	
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	
	public void paint(Graphics g){
		if (isClicked) {
			Color c = g.getColor();
			g.setColor(Color.WHITE);
			g.drawRoundRect(x, y,Utils.RECT_WIDTH,Utils.RECT_HEIGHT,25,25);
			g.setColor(c);
		}
		g.drawImage(show,x,y,Utils.RECT_WIDTH,Utils.RECT_HEIGHT,null);
	}
	
	public Image getShow() {
		return show;
	}
	public void setShow() {
		switch (type) {
		case 0:
			show = Utils.blue.getImage();
			break;
		case 1:
			show = Utils.green.getImage();
			break;
		case 2:
			show = Utils.orange.getImage();
			break;
		case 3:
			show = Utils.purple.getImage();
			break;
		case 4:
			show = Utils.red.getImage();
			break;
		default:
			break;
		}
	}
	public boolean isClicked() {
		return isClicked;
	}
	public void setClicked(boolean isClicked) {
		this.isClicked = isClicked;
	}
}














